<?php 
require_once $_SERVER["DOCUMENT_ROOT"]."/inc/core/env.inc.php";

$return["success"] = false; 
$return["html"] = null;
$return["error"] = null;

if ($_USER->login) {
	$return['success'] = true;
	$return['html'] = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-rows.tag.html');
	
	$rowPermission = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-row.tag.html');
	$col = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-col.tag.html');
	
	$res = $_USER->getPermissions();
	$altActive =  $_TRANSLATE->traslate('{VOCABULARY|permission_active}', $_SESSION["LANGUAGE"]);
	$ico = '<img src="/inc/templates/default/img/ico/admin/permission-true.gif" alt="'.$altActive.'" />';
	
	$rowClass = 'row-permission-view';
	$rows = '<li><div><b>Permissions view</b></div><div><b>Permission name</b></div><br class="clearboth"></li>';
	foreach ($res as $ele) {

		$description = str_replace($_TAGS["share-content-col"], $ico, $col);
		$description .= str_replace($_TAGS["share-content-col"], $_TRANSLATE->traslate('{VOCABULARY|'.$ele.'}', $_SESSION["LANGUAGE"]), $col);
			
		$row = str_replace($_TAGS['admin-row-class'], $rowClass, $rowPermission);
		$rows .= str_replace($_TAGS['share-content-columns'], $description, $row);
	}
	
	$return['html'] = str_replace($_TAGS['admin-rows'], $rows, $return['html']);
	
} else {
	$return["error"] = $_TRANSLATE->traslate('{VOCABULARY|permission_disactive}', $_SESSION['LANGUAGE']);
}

echo '('.json_encode($return).')';
?>